import java.util.Scanner;

import controller.IMenuController;
import controller.MenuController;
import functionality.IListener;
import functionality.Listener;
import boundary.IMenu;
import boundary.Menu;


public class Main {

	public static void main(String[] args) {
		int port;
		
		if (args.length == 1)
			port = Integer.parseInt(args[0]);
		else 
			port = 8000;
		
		Scanner scan = new Scanner(System.in);
		IMenu menu = new Menu(scan);
		IMenuController menuC = new MenuController(menu);
		IListener listen = new Listener(menu, port);
		
		Thread menuThread = new Thread((Runnable) menuC);
		Thread listenThread = new Thread((Runnable) listen);
		
		menuThread.start();
		listenThread.start();
		
		try {
			menuThread.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		scan.close();
		
	}

}
